package com.zxq.ruoyi.network.tcp.handler.impl.modbus;

import com.zxq.ruoyi.network.tcp.handler.impl.TCPModbusPoxyHandler;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.PostConstruct;

@Slf4j
public abstract  class AbsModbusRegister   {


    /**
     * 注册服务
     */
    @PostConstruct
    public void registerProxy(){
        Short hex_transactionId = getTransactionId();
        Short hex_protocolId = getProtocolId();
        String headKey = String.format("%04x%04x",hex_transactionId,hex_protocolId);
        log.info(String.format("modbus frame register, headKey:%s, type:%s",headKey,getClass().getSimpleName()));
        TCPModbusPoxyHandler.frameRegister.put(headKey, this);
    }

    /**
     * 事务标志
     */
    protected abstract Short getTransactionId();

    /**
     * 协议标志
     */
    protected abstract Short getProtocolId();



}
